/*
 * Created on Aug 26, 2008
 * (c) 2008 by Tenereillo, Inc.
 */
package ro.letsdoitromania.forms;

import javax.microedition.lcdui.*;
import ro.letsdoitromania.LDIRCanvas;
import ro.letsdoitromania.LDIRMidlet;
import ro.letsdoitromania.LDIRSettings;
import com.mgmaps.app.APPCommands;
import com.mgmaps.tools.UITools;
import com.mgmaps.utils.LS;

public class AboutForm implements CommandListener {
  private Form form;

  private StringItem siAbout;
  
  private static AboutForm instance;
  private String language;
  
  public static AboutForm getInstance() {
    if (instance == null)
      instance = new AboutForm();
    return instance;
  }
  
  private AboutForm() {
    language = LDIRSettings.language;
  }
  
  private void resetForm() {
    siAbout = null;
  }

  public void show() {
    if (language != LDIRSettings.language)
      resetForm();
    
    if (siAbout == null)
      siAbout = new StringItem("", LS.get("app.about.contents", new String[] { LDIRSettings.version, LDIRSettings.UPDATED }));

    form = UITools.buildForm(form, LS.get("app.about.title"),
        new Item[] { siAbout },
        new Command[] { APPCommands.instance.backCommand }, this);
    
    Display.getDisplay(LDIRMidlet.instance).setCurrent(form);    
  }

  public void commandAction(Command cmd, Displayable disp) {
    Display.getDisplay(LDIRMidlet.instance).setCurrent(LDIRCanvas.instance);
  }
}
